﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Effects;

namespace Beetle.Sl.EditorControl.Effects
{
    /// <summary>
    /// 灰度特效
    /// </summary>
    public class GrayEffect : ShaderEffect
    {
        public static DependencyProperty InputProperty = ShaderEffect.RegisterPixelShaderSamplerProperty("Input", typeof(GrayEffect), 0);

        public static DependencyProperty FactorProperty = DependencyProperty.Register("Factor", typeof(double), typeof(GrayEffect), new PropertyMetadata(new double(), PixelShaderConstantCallback(0)));

        public GrayEffect()
        {
            this.PixelShader = new PixelShader()
            {
                UriSource = new Uri("/Beetle.Sl.EditorControl;component/Effects/Source/Gray.ps", UriKind.Relative)
            };

            this.UpdateShaderValue(InputProperty);
            this.UpdateShaderValue(FactorProperty);
        }

        public virtual System.Windows.Media.Brush Input
        {
            get
            {
                return ((System.Windows.Media.Brush)(GetValue(InputProperty)));
            }
            set
            {
                SetValue(InputProperty, value);
            }
        }

        public virtual double Factor
        {
            get
            {
                return ((double)(GetValue(FactorProperty)));
            }
            set
            {
                SetValue(FactorProperty, value);
            }
        }
    }
}
